package main;

/**
 * 能够整体地替换算法，能让我们轻松地以不同的算法去解决同一个问题，这种模式就是Strategy模式。
 *
 *
 */
public class Main {

    public static void main(String[] args) {
        Player player1 = new Player("张三", new WinningStrategy());
        Player player2 = new Player("李四", new ProbStrategy());
        for (int i = 0; i < 100; i++) {
            Hand nextHand1 = player1.nextHand();
            Hand nextHand2 = player2.nextHand();
            if (nextHand1.isStrongerThan(nextHand2)){
                System.out.println("Winner: " + player1);
                player1.win();
                player2.lose();
            }else if (nextHand1.isWeakerThan(nextHand2)){
                System.out.println("Winner: " + player2);
                player1.lose();
                player2.win();
            }else {
                System.out.println("Even...");
                player1.even();
                player2.even();
            }
        }
        System.out.println("Total result: ");
        System.out.println(player1);
        System.out.println(player2);
    }

}
